<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选择父节点</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.js"></script>
    <script src="../../js/jquery.js"></script>
    <script src="../../js/myAjax.js"></script>
</head>
<body>
<div style="display: flex;margin-top: 30px;margin-left: 10px">
    <div style="color: #009E94">请选择父节点：</div>
    <div id="add-permission" style="background-color: #a0eeea;"></div>
</div>
</body>
<script>
    layui.use('tree', function () {
        var tree = layui.tree;

        function findParent() {
            let result = myAjax('/p/permission/persTree', 'get', {});
            // let data = result;
            return result;
        }

        let per = findParent();
        //渲染
        tree.render({
            elem: '#add-permission'  //绑定元素
            , data: [per]
            , edit: ['add', 'update', 'del'] //操作节点的图标
            , click: function (obj) {
                let pid = obj.data.id;
                sessionStorage.setItem("pid", pid);
                parent.layer.closeAll();
                parent.layer.open({
                    type: 2,
                    anim: 3,
                    title: '添加权限',
                    area: ['600px', '500px'],
                    shadeClose: true, //点击遮罩关闭
                    content: ['/html/permission/addPermission.html', 'no'],
                })
            }
        });

    });
</script>
</html>